package text2;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class client {
    public static void main(String[] args) throws IOException {

        Socket socket = new Socket("127.0.0.1", 10003);
        //获取输出流,发送数据
        OutputStream os = socket.getOutputStream();
        os.write("iam so happy".getBytes());



        socket.shutdownOutput();//对发送端输出的数据做一个结束

        //发送端接受回接收端输出回来的信息
        InputStream is = socket.getInputStream();
        int b;
        while ((b=is.read())!=-1)
        {
            System.out.print((char)b);
        }

        socket.close();

    }
}
